package com.wuyou.simple;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;

/**
 * 1710. 卡车上的最大单元数
 */
public class MaximumUnits {


    public static void main(String[] args) {
        int[][] boxTypes = {{5,10},{2,5},{4,7},{3,9}};
        int truckSize = 10;
//        System.out.println(solution_1(boxTypes, truckSize));

        Date date = new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_YEAR) + 1, 23, 59, 59);

        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()));

    }


    public static int solution_1(int[][] boxTypes, int truckSize) {
        int res = 0, temp = truckSize;
        Arrays.sort(boxTypes, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o2[1] - o1[1];
            }
        });
        for (int i = 0; i < boxTypes.length; i++) {
            if (temp - boxTypes[i][0] >= 0) {
                res += (boxTypes[i][0] * boxTypes[i][1]);
                temp -= boxTypes[i][0];
            } else {
                res += (temp * boxTypes[i][1]);
                temp = 0;
            }
            if (temp == 0) {
                break;
            }
        }
        return res;
    }
}
